home *** CD-ROM | disk | FTP | other *** search
/ Mac Mania 4 / MacMania 4.toast / / Demo's / Igor Demo Pro / 1 PutContentsIn Igor Pro Folder / WaveMetrics Procedures / Analysis / Median < prev    next >
Text File  |  1995-12-31  |  533b  |  21 lines

  1. #pragma rtGlobals=1
  2.  
  3. | Median(w, x1, x2)
  4. |    Based on Numerical Recipes in C pp. 476-477.
  5. |    Returns median value of wave w from x=x1 to x=x2.
  6. |    Pass -INF and +INF for x1 and x2 to get median of the entire wave.
  7. Function Median(w, x1, x2)
  8.     Wave w
  9.     Variable x1, x2
  10.     
  11.     Variable result
  12.  
  13.     Duplicate/R=(x1, x2) w, tempMedianWave            | Make a clone of wave
  14.     Sort tempMedianWave, tempMedianWave            | Sort clone
  15.     SetScale/P x 0,1,tempMedianWave
  16.     result = tempMedianWave((numpnts(tempMedianWave)-1)/2)
  17.     KillWaves tempMedianWave
  18.  
  19.     return result
  20. End
  21.